package com.eascs.ticket.configuration.controller;

import javax.inject.Inject;

import org.springframework.web.bind.annotation.RestController;

import com.eascs.common.util.StringUtil;
import com.eascs.site.controller.BaseRestController;
import com.eascs.site.view.BaseRestResult;
import com.eascs.ticket.configuration.form.DbForm;
import com.eascs.ticket.configuration.service.DbService;

@RestController
public class DbRestController extends BaseRestController {
	@Inject
	private DbService dbService;

	// @RequestMapping("/configuration/db/execute")
	public BaseRestResult<Integer> execute(DbForm dbForm) {
		int result = 0;
		if (StringUtil.hasText(dbForm.getSql())) {
			result = this.dbService.execute(dbForm.getSql());
		}
		return BaseRestResult.buildRestResult(result);
	}

}
